package com.wang.web3;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.wang.web3.adapter.ViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class IntoWalletActivity extends AppCompatActivity {

    private ViewPagerAdapter exchangePagerAdapter;
    private TabLayout tablayout;
    private ViewPager viewpager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_into_wallet);
        initView();
        initViewPager();
    }

    private void initViewPager() {

        // 创建一个集合,装填Fragment
        ArrayList<Fragment> fragments = new ArrayList<>();
        List<String> mTitlsList = new ArrayList<>();
        IntoWordsFragment mFragment1 = IntoWordsFragment.newInstance();
        IntoStoreFragment mFragment2 = IntoStoreFragment.newInstance();
        IntokeyFragment mFragment3 = IntokeyFragment.newInstance();

        fragments.add(mFragment1);
        fragments.add(mFragment2);
        fragments.add(mFragment3);

        mTitlsList.add("助记词");
        mTitlsList.add("官方钱包");
        mTitlsList.add("私钥");

        exchangePagerAdapter = new ViewPagerAdapter(this.getSupportFragmentManager(), this, fragments, mTitlsList);
        viewpager.setAdapter(exchangePagerAdapter);
        viewpager.setOffscreenPageLimit(fragments.size());

        tablayout.setupWithViewPager(viewpager);
        tablayout.setTabMode(TabLayout.MODE_FIXED);

    }

    private void initView() {
        tablayout = findViewById(R.id.tv_tablayout);
        viewpager = findViewById(R.id.tv_viewpager);
    }

}
